import unittest
import time
import os
from scripts.constant import REPORT_DIR,CASES_DIR,USER_CONFIG_FILEME
from libs.HTMLTestRunnerNew import HTMLTestRunner
from scripts.handle_user import generate_users_config

if not os.path.exists(USER_CONFIG_FILEME):
    generate_users_config()


suite = unittest.defaultTestLoader.discover(start_dir=CASES_DIR, pattern="test*.py")

current_time = time.strftime("%Y%m%d_%H%M%S",time.localtime())
report_filename = os.path.join(REPORT_DIR, (str(current_time) + "report.html"))
with open(report_filename, "wb") as one_file:
    run2 = HTMLTestRunner(stream=one_file,
                          title="第一份测试报告",
                          description="html报告生成",
                          verbosity=1,
                          tester="老王")
    run2.run(suite)


